home *** CD-ROM | disk | FTP | other *** search
- ; Save a standard palette (PPaint palette)
- ; By : Cyanure (Mathias.P@wanadoo.fr)
- ; Date : 26/07/98
-
- Statement SavePaletteFile{NumberBmap.b,FileName.s}
- DEFTYPE .b NumberPlanes
- DEFTYPE .w NumberColors,FSize
-
- NumberPlanes=Peek.b(Addr BitMap(NumberBmap)+5)
- NumberColors=2^NumberPlanes
- FSize=3*NumberColors+48 ; File size
-
- If OpenFile(1,FileName.s)=-1
- *pf=AllocMem_(FSize,0) ; Memory for the palette file
- *pf0=*pf ; Beginning of the palette file
- address
- Poke.l *pf,$464f524d ; FORM
- Poke.l *pf+4,FSize-8 ;
- Poke.l *pf+8,$494c424d ; ILBM
- Poke.l *pf+12,$424d4844 ; BMHD
- Poke.l *pf+16,20 ; Size of the BMHD chunk
- Poke.l *pf+20,0 ; width and height
- Poke.l *pf+24,0 ; x and y
- Poke.l *pf+28,$03020180 ; I don't know why but it works !
- Poke.l *pf+32,0 ; transparency and aspect
- Poke.l *pf+36,0 ; page width and page height
- Poke.l *pf+40,$434d4150 ; CMAP
- Poke.l *pf+44,NumberColors*3 ; Size of the CMAP chunk
-
- *pf+48 ; Increases the pointer
-
- For c=0 To NumberColors-1
- Poke.b *pf,AGARed(c)
- Poke.b *pf+1,AGAGreen(c)
- Poke.b *pf+2,AGABlue(c)
- *pf+3
- Next c
-
- WriteMem 1,*pf0,FSize ; Writes in file #1
- FreeMem_ *pf0,FSize
- CloseFile 1
-
- EndIf
-
- End Statement
-
- .main
-
- WBStartup
- NoCli
-
- ; I suppose the palette you want to save is one of an open bitmap
- ; So, I open such a bitmap :
- Screen 0,0,0,320,256,8,0,"title",1,2
- ScreensBitMap 0,0
- LoadBitMap 0,"images:iff/ofs.iff",0 ; chooses a bitmap
- LoadPalette 0,"images:iff/ofs.iff"
- Use Palette 0
-
- SavePaletteFile{0,"ram:PaletteStd.col"}
-
- End
-
-
-
-
-